<template>
  <div class="app-container">

    <audio></audio>
    <el-table
      v-loading="loading"
      :data="tableData"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="50" align="center" />
      <el-table-column label="文件名称" align="center" prop="tapeName" />
      <el-table-column label="创建时间" align="center" prop="createTime" />
      <el-table-column
        label="文件数"
        align="center"
        prop="fileQuantity"
      ></el-table-column>
      <el-table-column label="文件大小" align="center" prop="fileSize" />
      <el-table-column label="下载次数" align="center" prop="downloadNumber" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            v-if="scope.row.ttsUrl"
            @click="onAudioDownload(scope.row)"
            type="text"
            >下载</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="pagination.pageNum"
      :limit.sync="pagination.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { downloadList } from "@/api/dataManagement/downloadRecord.js";
export default {
  name: "downloadRecord",
  data() {
    return {
      loading: false,
      tableData: [], //表格数据
      showSearch: true, //显示搜索条件
      // 查询参数
      formData: {
        chatText: "", //测试文本
        voiceType: "", //音色
        pitchRatio: "", //音高
        speedRatio: "", //语速
      },
      voiceTypeList: [], //音色数据
      pagination: {
        pageNum: 1,
        pageSize: 10,
      },
      dateRange: [], //日期范围
      total: 0,
      importShow: false, //导入
      addDialogShow: false,
      voiceTypeList: [],
    };
  },
   created() {
     this.getList();
  },
  methods: {
    // 列表查询
    async getList() {
      const { total, rows } = await downloadList();
      this.total = total;
      this.tableData = rows;
      this.loading = false;
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.pagination.pageNum = 1;
      this.getList();
    },

   

    // 音频下载
    async onAudioDownload(row) {
      // console.log(row, "row");
      // const fileUrl = row?.ttsUrl;
      // // 打开新标签页进行下载
      // window.open(fileUrl, "_blank");
    },

    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.userId);
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },

  },
};
</script>

<style lang="scss" scoped></style>
